package stackandqueue.stack.test;

import stackandqueue.stack.inter.Stack;
import stackandqueue.stack.linkedstack.LinkedStack;
import stackandqueue.stack.sequentialstack.SqStack;

public class Main {
    public static void main(String[] args) {
        Stack stack = new LinkedStack();
        stackTest(stack);
    }

    public static void stackTest(Stack stack) {
        System.out.println("初始化栈。。。。。");
        System.out.println("栈元素个数：" + stack.stackLength());
        System.out.println("向栈中压入a,b,c,d,e,f,g:");
        for (int i = 0; i < 7; i++) {
            stack.push((char) ('a' + i));
        }
        System.out.println("栈元素个数：" + stack.stackLength());
        System.out.println("获取栈顶元素：" + stack.getTop());
        System.out.println("栈顶元素出栈：" + stack.pop());
        System.out.println("获取栈顶元素：" + stack.getTop());
        System.out.println("栈中所有元素出栈：");
        while (!stack.stackEmpty()) {
            System.out.print(stack.pop() + " ");
        }
        System.out.println();
        System.out.println("栈元素个数：" + stack.stackLength());

    }
}

